## 使用request
# 先导包 pip install requests
import requests

url = 'http://www.baidu.com/'
response = requests.get(url=url)

# 获取字符串
print('\n'*3)
print('【response.text】获取字符串')
print(response.text)

# 获取二进制
print('\n'*3)
print('【response.content】获取二进制')
print(response.content)

print('\n'*3)
print('【response.content 根据03】二进制能转字符串,注意字符集')
print(response.content.decode(encoding='UTF-8'))

print('\n'*3)
print('response.status_code【获取响应状态码】')
print(response.status_code)

print('\n'*3)
print('response.request.headers【请求头】')
print(response.request.headers)

print('\n'*3)
print('response.headers【响应求头】')
print(response.headers)

print('\n'*3)
print('response.cookies【响应cookies】')
print(response.cookies)

print('\n'*3)
print('response.request.cookies【请求cookies】 这个我没拿到 应该是版本问题')
print()